package com.supermap.application;

import com.supermap.application.annotation.RequestJsonHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.List;

/**
 * 新建配置类
 * 继承spring boot的 WebMvcConfigurerAdapter 注解配置类
 * 重写 addArgumentResolvers 方法
 */
@Configuration
@ComponentScan("com.supermap.application.annotation")
public class WebConfig extends WebMvcConfigurerAdapter {

    @Autowired
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers){
        argumentResolvers.add(new RequestJsonHandlerMethodArgumentResolver());
        super.addArgumentResolvers(argumentResolvers);
    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**");
    }

}
